package de.dnb.basics.filtering;

import de.dnb.basics.applicationComponents.RangeCheckUtils;

/**
 * Filterkriterium ODER.
 * 
 * @author Michael Inden
 * 
 * Copyright 2011 by Michael Inden 
 */
public class Or<T> implements IPredicate<T> {

	private final IPredicate<T>[] predicates;

	public Or(final IPredicate<T>... predicates) {
		for (IPredicate<T> predicate : predicates) {
			RangeCheckUtils
				.assertReferenceParamNotNull("filter", predicate);
		}
		this.predicates = predicates;
	}

	@Override
	public final boolean accept(final T object) {
		for (IPredicate<T> predicate : predicates) {
			if (predicate.accept(object))
				return true;
		}
		return false;
	}
}
